import type { PropsInterface } from './types/props'
export function useDarwer(props: PropsInterface) {
  // 加载状态
  const isLoading = ref(false)
  // 处理加载逻辑
  const useInnerLoading = () => {
    const isFunction = Object.prototype.toString.call(props.innerLoading) === '[object Function]'
    if (!isFunction) {
      return
    }
    isLoading.value = true
    props.innerLoading &&
      props
        .innerLoading()
        .then(() => {
          isLoading.value = false
        })
        .catch(() => {
          isLoading.value = false
        })
  }

  return {
    isLoading,
    useInnerLoading,
  }
}
